import storage from '../utils/storage'
import store from './../store'
import * as io from 'socket.io-client'

const socket = io.connect(
  process.env.NODE_ENV === 'production'
    ? 'ws://' + location.hostname + ':3000'
    : 'ws://localhost:3000'
)

/** {@typedef socket.emit.login} */
export default socket

/** 用户渲染 */
socket.on('pushUserArr', (user) => {
  store.commit('updatePushArr', user)
})
